package com.museum;

import java.io.IOException;
import java.io.StringReader;
import java.net.URI;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.Vector;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xmlrpc.android.XMLRPCClient;
import org.xmlrpc.android.XMLRPCException;

import com.museum.data.Mp_Places_Items_Handler;
import com.museum.data.Mp_Places_Museum_Handler;
import com.museum.data.Mp_Places_News_Handler;
import com.museum.data.Mp_User_Bookshelf_Handler;
import com.museum.data.Mp_User_Profile_Handler;
import com.museum.data.Mp_User_Visit_Handler;
import com.museum.data.Mp_User_Watched_Handler;
import com.museum.model.Location;
import com.museum.model.Mp_Places_Items;
import com.museum.model.Mp_Places_Museum;
import com.museum.model.Mp_User_Watched;
import com.museum.model.Open_Date;
import com.museum.model.Open_Date_Item;
import com.museum.model.Place;
import com.museum.model.Visited;
import com.museum.R;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.support.v4.app.NavUtils;
import android.view.View.OnClickListener;

public class Mp_Places_News_Activity extends Activity {
	TextView textviewDetail;
	
	private XMLRPCClient client;
	private URI uri;
	Visited visited;
	Place place;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mp_places_news);
        
        bindWidget();
        setButtonEventListener();
        
        String place_id = "57";
        String result = "";
      //##############Mp_Places_News##################
        Mp_Places_News_Handler e = new Mp_Places_News_Handler(place_id);
        for(int i = 0;i < e.get_Mp_Places_News().getItemCount(); i++){
      	  String event_id = e.get_Mp_Places_News().getItem(i).getEvent_id();
      	  String display_name = e.get_Mp_Places_News().getItem(i).getDisplay_name();
      	  String description = e.get_Mp_Places_News().getItem(i).getDescription();
      	  result += "\r\nevent_id: " + event_id
    			 +"\r\n"+ "display_name: "+ display_name
    			 +"\r\n"+ "description: "+ description;
      	  
	      	String placeinfo_id = e.get_Mp_Places_News().getItem(i).getPlace_info().getPlaceId();
	       	String name = e.get_Mp_Places_News().getItem(i).getPlace_info().getName();
	   	    String place_news_description = e.get_Mp_Places_News().getItem(i).getPlace_info().getDescription();
	   	    String create_timestamp = e.get_Mp_Places_News().getItem(i).getPlace_info().getCreate_Timestamp();
	   	    String add_timestamp = e.get_Mp_Places_News().getItem(i).getPlace_info().getAdded_Timestamp();
	   	    String location_description = e.get_Mp_Places_News().getItem(i).getPlace_info().getDescription();
	   	    String location_latitude = e.get_Mp_Places_News().getItem(i).getPlace_info().getLocation().getLatitude();
	   	    String location_longitude = e.get_Mp_Places_News().getItem(i).getPlace_info().getLocation().getLongitude();
	   	    String website = e.get_Mp_Places_News().getItem(i).getPlace_info().getWebsite();
	   	    String placeinfo_email = e.get_Mp_Places_News().getItem(i).getPlace_info().getEmail();
   	    
	      	result += "\r\nplace_id: " + placeinfo_id
	     			 +"\r\n"+ "name: "+ name
	     			 +"\r\n"+ "description: "+ place_news_description
	     			 +"\r\n"+ "create_timestamp: "+ create_timestamp
	     			 +"\r\n"+ "add_timestamp: "+ add_timestamp
	     			 +"\r\n"+ " location_description: "+ location_description
	     			 +"\r\n"+ " location_latitude: "+ location_latitude
	     			 +"\r\n"+ " location_longitude: "+ location_longitude
	     			 +"\r\n"+ "website: "+ website
	     			 +"\r\n"+ "email: "+ placeinfo_email;
	      	
          String start_date = e.get_Mp_Places_News().getItem(i).getStart_date();
          String end_date = e.get_Mp_Places_News().getItem(i).getEnd_date();
          String event_type = e.get_Mp_Places_News().getItem(i).getEvent_type();
          String flee = e.get_Mp_Places_News().getItem(i).getFlee();
          String web_site = e.get_Mp_Places_News().getItem(i).getWeb_site();
          String email = e.get_Mp_Places_News().getItem(i).getEmail();
          String phone_number = e.get_Mp_Places_News().getItem(i).getPhone_number();
          result += "\r\n"+ " open_date: "+ start_date
      			+"\r\n"+ "end_date: "+ end_date
		        	+"\r\n"+ "event_type: "+ event_type
		        	+"\r\n"+ "flee: "+ flee
		        	+"\r\n"+ "web_site: "+ web_site
		        	+"\r\n"+ "email: "+ email
		        	+"\r\n"+ "phone_number: "+ phone_number;
        }
        textviewDetail.setText(result);
    }
    private void bindWidget(){
    	textviewDetail = (TextView)findViewById(R.id.textviewDetail);
    }
    private void setButtonEventListener(){

    }

}
